#ifndef __THREADPOOL__
#define __THREADPOOL__

#include "worker.h"
#include "taskQueue.h"

#include <54func.h>

typedef enum msgCode_s{
    CLOSE_CONNECT,
    REGISTER_APPLY, REGISTER_OK, REGISTER_FAID,
    LOGIN_APPLY, LOGIN_OK, LOGIN_FAID,
    LS_APPLY, LS_OK, LS_FAID,
    CD_APPLY, CD_OK, CD_FAID,
    PWD_APPLY, PWD_OK, PWD_FAID,
    PUTS_APPLY, PUTS_OK, PUTS_FAID,
    GETS_APPLY, GETS_OK, GETS_FAID,
    RM_APPLY, RM_OK, RM_FAID,
    MKDIR_APPLY, MKDIR_OK, MKDIR_FAID,
    RMDIR_APPLY, RMDIR_OK, RMDIR_FAID,
}msgCode_t;

typedef struct train_s{
    int length;
    char data[1000];
    int code;//状态码
}train_t;

typedef struct threadPool_s{
    //线程
    tidArr_t tidArr;
    //任务队列
    taskQueue_t taskQueue;
    //互斥锁
    pthread_mutex_t mutex;
    //条件变量
    pthread_cond_t cond;
    //退出标志位
    int exitFlag;
}threadPool_t; 

int threadPoolInit(threadPool_t *pthreadPool, int workerNum);
int makeWorker(threadPool_t *pthreadPool);

int tcpInit(int *psockFd, const char *ip, const char *port);
int epollAdd(int epfd, int fd);
int epollDel(int epfd, int fd);

#endif